package com.esreport.Utils;


import org.springframework.util.StringUtils;

import java.net.MalformedURLException;
import java.net.URL;

/**
 * @author xuweiwei
 * @date 2019/7/4
 */
public class UrlUtil {

    public static boolean valid(String url) {
        try {
            URL url1 = new URL(url);
            return true;
        } catch (MalformedURLException e) {
            return false;
        }
    }

    public static  String join(String prefix, String url) {
        if(valid(url)){
            return url;
        }
        if(valid(prefix)){
            try {
                return new URL(new URL(prefix),url).toString();
            } catch (MalformedURLException e) {
            }
        }
        return "";
    }

    public static void main(String[] args) {
        System.out.println(join("http://webtv3.i2863.com/index.html","upload/Image/mrtp/1_5e7a8178a06149e48bc502238d5f3d71.jpg"));
    }
}
